package com.css.zfzx.sjcj.modules.hddcTrench.repository;

import com.css.zfzx.sjcj.modules.hddcA1InvRgnHasMaterialTable.repository.entity.HddcA1InvrgnhasmaterialtableEntity;
import com.css.zfzx.sjcj.modules.hddcTrench.repository.entity.HddcTrenchEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author zyb
 * @date 2020-11-27
 */
public interface HddcTrenchRepository extends JpaRepository<HddcTrenchEntity, String> {
    @Query(nativeQuery = true,value="select w.* from hddc_trench  w where w.id=?1 and w.is_valid=1")
    HddcTrenchEntity findbyId(String id);
    @Modifying
    @Query(nativeQuery = true,value = "update hddc_trench set qualityinspection_status=:qualityinspection_status ,extends1=:extend1 where uuid=:uuid")
    void updateStatus(@Param("qualityinspection_status") String qualityinspection_status, @Param("extend1") String extend1, @Param("uuid")String uuid);

    @Modifying
    @Query(nativeQuery = true,value = "update hddc_trench set qualityinspection_status=:qualityinspection_status ,extends2=:extend2 where geologysvyprojectid=:geologysvyprojectid")
    void update2Status(@Param("qualityinspection_status") String qualityinspection_status,@Param("extend2") String extend2,@Param("geologysvyprojectid")String geologysvyprojectid);

    @Query(nativeQuery = true,value = "select * from hddc_trench where is_valid=1 and (qualityinspection_status!=3 or qualityinspection_status is null)")
    List<HddcTrenchEntity> findByAll();

    HddcTrenchEntity findByUuidAndIsValid(String id, String isValid);
}
